var i=0; 
              
function checkAll(swch){
	len=document.mailbox.elements.length;
	for (i=0;i<len;i++){
		if (document.mailbox.elements[i].type=='checkbox'){
			document.mailbox.elements[i].checked=true;
		};
	}; 
};

function checkRead(swch){
	uncheckAll();
	len=document.mailbox.elements.length;
	for (i=0;i<len;i++){
		if (document.mailbox.elements[i].type=='checkbox' && document.mailbox.elements[i].getAttribute('read') == 'true' ){
			document.mailbox.elements[i].checked=true;
		};
	}; 
};

function checkUnRead(swch){
	uncheckAll();
	len=document.mailbox.elements.length;
	for (i=0;i<len;i++){
		if (document.mailbox.elements[i].type=='checkbox' && document.mailbox.elements[i].getAttribute('read') == 'false' ){
			document.mailbox.elements[i].checked=true;
		};
	}; 
};

function uncheckAll(){
	len=document.mailbox.elements.length;
	for (i=0;i<len;i++){
		if (document.mailbox.elements[i].type=='checkbox'){
			document.mailbox.elements[i].checked=false;
		};
	}; 
};

function confirmDeleteAll(){
	if(confirm('Cancello tutti i messaggi selezionati?'))
		{return true;}
	else
		{return false;}
};

function hideCCN(){
	var ccn = document.getElementById('CCN'); 

	ccn.style.visibility='hidden';
};

function showCCN(i){
	var cc = document.getElementById('CC'); 
	var ccn = document.getElementById('CCN'); 
	var accn = document.getElementById('ADDCCN'); 
	var accc = document.getElementById('ADDCCC'); 
	var acc2 = document.getElementById('ADDCCN2'); 

	ccn.style.visibility='visible';
	ccn.style.position='relative';
	ccn.style.width='100%';
	
	accn.style.visibility='hidden';
	accn.style.position='absolute';
	if( i == 1 ) {
		accc.style.visibility='hidden';
		accc.style.position='absolute';
	}

	if( cc.style.visibility == "visible" ) {
		acc2.style.visibility='hidden';
		acc2.style.position='absolute';
		accc.style.visibility='hidden';
		accc.style.position='absolute';
	}	
	
};

function showCC(i){

	var cc = document.getElementById('CC'); 
	var ccn = document.getElementById('CCN'); 
	var acc = document.getElementById('ADDCC'); 
	var accc = document.getElementById('ADDCCC'); 
	var acc2 = document.getElementById('ADDCCN2'); 

	cc.style.visibility='visible';
	cc.style.position='relative';
	cc.style.width='100%';

	acc.style.visibility='hidden';
	acc.style.position='relative';

	if( accc ) {
		accc.style.visibility='hidden';
		accc.style.position='absolute';
	}

	if( ccn.style.visibility != "visible" ) {
		acc2.style.visibility='visible';
		acc2.style.position='relative';
		acc2.style.width='100%';
	}	
};